import cv2
import numpy as np


img = cv2.imread('img_1.png')
img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
mask_red = cv2.inRange(img, np.array([0, 43, 46]), np.array([255, 255, 255]))
mask_orange = cv2.inRange(img, np.array([156, 43, 46]), np.array([180, 255, 255]))
result = cv2.bitwise_and(img, img, mask=mask_red)
ones = np.ones([img.shape[0], img.shape[1]], np.uint8)
print(ones.shape, mask_red.shape)
result1 = 255 * (ones - (ones - mask_red/255).dot((ones - mask_orange/255)))

cv2.imshow("original", img)
cv2.imshow("red", mask_red)
cv2.imshow("orange", mask_orange)
cv2.imshow("result1", result)
cv2.imshow("result2", result1)

cv2.waitKey()
cv2.destroyAllWindows()
